<template>
  <div>
    御剑乘风来,除魔天地间!
    <van-form @submit="onSubmit">
      <van-field
        :rules="rulesObj.ruleArr"
        label="手机号"
        label-align="left"
        label-width="80px"
        name="手机号"
        placeholder="手机号"
        v-model="username"
      />
      <van-field
        :rules="rulesObj.rulePas"
        label="密码"
        label-align="left"
        label-width="80px"
        name="密码"
        placeholder="密码"
        type="password"
        v-model="password"
      />

      <van-field center clearable label="短信验证码" placeholder="请输入短信验证码" v-model="sms">
        <template v-slot:button>
          <van-button size="small" type="primary">发送验证码</van-button>
        </template>
      </van-field>
      <div style="margin: 16px;">
        <van-button block native-type="submit" round type="info">提交</van-button>
      </div>
    </van-form>
  </div>
</template>

<script>
const userHandle = (value,rule)=>{
  console.log(value,rule,88)
  var reg = /^(0|86|17951)?(13[0-9]|15[012356789]|166|17[3678]|18[0-9]|14[57])[0-9]{8}$/
  var flag = reg.test(value)
  return flag
}
export default{
    data () {
        return {
         username:'',
         password:'',
         sms:'',
        /* 表单校验 */
        rulesObj:{
          ruleArr:[
            {required:true,message:'请填写账号'},
            {validator:userHandle,message:'请输入合法手机号'}
             // { pattern: /^(0|86|17951)?(13[0-9]|15[012356789]|166|17[3678]|18[0-9]|14[57])[0-9]{8}$/, message: '请填写合法手机号' }
          ],
          rulePas:[
            {required:true,message:'请填写密码'}
          ]
        }

        }
    },
    created () {
    },
    computed:{
    },
    methods:{
      onsubmit (values){
        console.log(submit,values,88)
        
      }
    }
}
</script>
<style lang='less'  scoped>
    
</style>
